package com.home766.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import net.biz.entity.OrderEntity;

import javax.persistence.*;
import java.util.List;


@Entity
@Table(name = "766_dictionary")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "766_dictionary_sequence")
public class Dictionary extends OrderEntity {
	private static final long serialVersionUID = -4976120547288856150L;
	/**标题*/
	private String title;
	/**描述*/
	private String description;
	/**
	 * 上级
	 */
	private Dictionary parent;
	/**
	 * 下级
	 */
	private List<Dictionary> childrens;
	/**是否有效*/
	private Boolean flag;
	@JsonProperty
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@JsonProperty
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	public Dictionary getParent() {
		return parent;
	}
	public void setParent(Dictionary parent) {
		this.parent = parent;
	}
	@JsonProperty
	@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY,cascade = CascadeType.REMOVE)
	@OrderBy("order asc")
	public List<Dictionary> getChildrens() {
		return childrens;
	}
	public void setChildrens(List<Dictionary> childrens) {
		this.childrens = childrens;
	}
	@JsonProperty
	public Boolean getFlag() {
		return flag;
	}
	public void setFlag(Boolean flag) {
		this.flag = flag;
	}
}
